new Handle:hudTitle;
new Handle:hudDescription;
new Handle:hudSuivi;

public Action:ShowAchievementHUD(Handle:timer, any:client)
{
	if(IsValidClient(client))
	{
		if(g_CLIENTSHOWACH[client] != 0)
		{
			new strAchid = FindValueInArray(g_LIST_ACHIEVEMENTS_ID,g_CLIENTSHOWACH[client]);
			if(strAchid !=-1)
			{
				new String:strNameAch[512];
				GetArrayString	(g_LIST_ACHIEVEMENTS_NAME,strAchid,strNameAch,sizeof(strNameAch));
				new String:strDescAch[512];
				GetArrayString	(g_LIST_ACHIEVEMENTS_DESCRIPTION,strAchid,strDescAch,sizeof(strDescAch));
				new strAmount;
				new String:strNameAll[1024];
				new String:strSteamId[64];
				new String:strId[128];
				strAmount = GetArrayCell(g_LIST_ACHIEVEMENTS_TRIGGERS,strAchid);
				new strReset;
				strReset = GetArrayCell(g_LIST_ACHIEVEMENTS_RESETDEATH,strAchid);
		
				if(strReset == 0)
				{
					new strUserAmount;
					GetClientAuthString(client, strSteamId, sizeof(strSteamId));
					Format(strId,sizeof(strId),"%s__%d",strSteamId,g_CLIENTSHOWACH[client]);
					new i = FindStringInArray(g_LIST_USERS_ACH_ID, strId);
					if(i != -1)
					{
						strUserAmount = GetArrayCell(g_LIST_USERS_ACH_STATUS,i);
					}
					else
					{
						strUserAmount = 0;
					}
					Format	(strNameAll,sizeof(strNameAll),"%s (%i/%i)",strNameAch, strUserAmount, strAmount);
					SetHudTextParams(0.01, 0.01, 2.0, 157, 195, 76, 0);
					ShowSyncHudText(client, hudTitle, strNameAll);
				}
				else
				{
					if(strReset == 1)
					{
						Format	(strNameAll,sizeof(strNameAll),"%s (%T)",strNameAch, "In one life", LANG_SERVER);
						SetHudTextParams(0.01, 0.01, 2.0, 157, 195, 76, 0);
						ShowSyncHudText(client, hudTitle, strNameAll);
					}
					else
					{
						if(strAmount == -1 || strAmount == 0)
						{
							Format	(strNameAll,sizeof(strNameAll),"%s (%T)",strNameAch, "In one round", LANG_SERVER);
						}
						else
						{
							new strUserAmount;
							GetClientAuthString(client, strSteamId, sizeof(strSteamId));
							Format(strId,sizeof(strId),"%s__%d",strSteamId,g_CLIENTSHOWACH[client]);
							new i = FindStringInArray(g_LIST_USERS_ACH_ID, strId);
							if(i != -1)
							{
								strUserAmount = GetArrayCell(g_LIST_USERS_ACH_STATUS,i);
							}
							else
							{
								strUserAmount = 0;
							}
							Format	(strNameAll,sizeof(strNameAll),"%s (%i/%i - %T)",strNameAch, strUserAmount, strAmount, "In one round", LANG_SERVER);
						}
						SetHudTextParams(0.01, 0.01, 2.0, 157, 195, 76, 0);
						ShowSyncHudText(client, hudTitle, strNameAll);
					}
				}
				
				SetHudTextParams(0.01, 0.04, 2.0, 233, 233, 233, 0);
				ShowSyncHudText(client, hudDescription, strDescAch);
				CreateTimer(2.0, ShowAchievementHUD, client);
			}
		}
	}
	else
	{
		g_CLIENTSHOWACH[client] = 0;
	}
}



/*---------------------------------------------------------------------------------
C U S T O M   A C H I E V E M E N T S
O P T I O N 5 : S H OW  H U D  A C H I E V E M E N T S
* A C H I E V E M E N T S  N O T  D O N E  O R  D O N E
---------------------------------------------------------------------------------*/
Handle:Panel_Menu_Option5(argclient)
{
	new String:strMessageTitle[255];
	new String:strAch_Title[255];
	new String:strExit[255];
	new strNumberachievement;
	new strNumberachievementdone;
	new String:strSteamidofclient[100];
	new Handle:strPanel;
	GetClientAuthString(argclient, strSteamidofclient, sizeof(strSteamidofclient));
	strNumberachievement = g_MAXACHIEVEMENTS;
	
	//Number of achievements of the player
	strNumberachievementdone = CountAchievementDone(argclient);
	Format(strMessageTitle, sizeof(strMessageTitle), "%T", "Option show HUD achievement", LANG_SERVER);
	if (strNumberachievementdone == strNumberachievement)
	{
		Format(strAch_Title, sizeof(strAch_Title), "%T", "No achievement in database", LANG_SERVER);
		strPanel =  CreatePanel();
		DrawPanelText(strPanel,"                                    ");
		DrawPanelText(strPanel,"                                    ");
		DrawPanelText(strPanel,strAch_Title);
		DrawPanelText(strPanel,"                                    ");
		DrawPanelText(strPanel,"                                    ");
		Format(strExit, sizeof(strExit), "%T", "Back", LANG_SERVER);
		DrawPanelItem(strPanel, strExit);
		SetPanelTitle(strPanel, strMessageTitle);
		SendPanelToClient(strPanel, argclient, PanelHandlerNULL, 20);
		MustCloseHandle(strPanel);
	}
	else
	{
		new Handle:strPanel3 = CreateMenu(PanelHandler5);
		for(new i = 0; i < g_MAXACHIEVEMENTS; i++) 
		{
			if(!IsClientAchDone(argclient,GetArrayCell(g_LIST_ACHIEVEMENTS_ID,i)))
			{
				GetArrayString	(g_LIST_ACHIEVEMENTS_NAME, i, strAch_Title, sizeof(strAch_Title));
				new String:NumAchievementInTable[64];
				IntToString(GetArrayCell(g_LIST_ACHIEVEMENTS_ID,i),NumAchievementInTable,sizeof(NumAchievementInTable));
				AddMenuItem(strPanel3,NumAchievementInTable,strAch_Title);
			}
		}
		SetMenuTitle(strPanel3, strMessageTitle);
		DisplayMenu(strPanel3,argclient,20);
		return strPanel3;
	}
	return INVALID_HANDLE;
}

/*---------------------------------------------------------------------------------
C U S T O M   A C H I E V E M E N T S
---------------------------------------------------------------------------------*/
public PanelHandler5 (Handle:argMenu, MenuAction:argAction, argParam1, argParam2)
{
	if (argAction == MenuAction_Select)
	{
		new String:info[64];
		GetMenuItem(argMenu, argParam2, info, sizeof(info));
		g_CLIENTSHOWACH[argParam1] = StringToInt(info);
		CreateTimer(0.1, ShowAchievementHUD, argParam1);
	} 
	else if (argAction == MenuAction_Cancel) {
		
		Panel_Menu(argParam1,0);
	}
	else if (argAction == MenuAction_End)
	{
		MustCloseHandle(argMenu);
	}
}